import { Badge, Tab, Tabs } from '@theme';

# Overview

## RsdoctorRspackPlugin

The **RsdoctorRspackPlugin** class is exported by `@rsdoctor/rspack-plugin`, and the configuration options are [RsdoctorRspackPluginOptions](#rsdoctorrspackpluginoptions).

<Tabs>

<Tab label="esm">

```ts
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';

new RsdoctorRspackPlugin({
  /** RsdoctorRspackPluginOptions */
});
```

</Tab>

<Tab label="cjs">

```js
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');

new RsdoctorRspackPlugin({
  /** RsdoctorRspackPluginOptions */
});
```

</Tab>

</Tabs>

## RsdoctorWebpackPlugin

The **RsdoctorWebpackPlugin** class is exported by `@rsdoctor/webpack-plugin`, and the configuration options are [RsdoctorWebpackPluginOptions](#rsdoctorwebpackpluginoptions).

<Tabs>

<Tab label="esm">

```ts
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';

new RsdoctorWebpackPlugin({
  /** RsdoctorWebpackPluginOptions */
});
```

</Tab>

<Tab label="cjs">

```js
const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');

new RsdoctorWebpackPlugin({
  /** RsdoctorWebpackPluginOptions */
});
```

</Tab>

</Tabs>

## Options

**Type:** `Object`

This `Options` object is the configuration for [RsdoctorRspackPlugin](#rsdoctorrspackplugin) and [RsdoctorWebpackPlugin](#rsdoctorwebpackplugin) . It contains the following properties:

- [disableClientServer](./disableClientServer.mdx) - **Client Service Control**: Whether to not automatically open the Rsdoctor report service after analysis is complete.
- [experiments](./experiments.mdx) - **Experimental Features Configuration**: Enable experimental features for Rspack plugins, such as native plugin performance optimization.
- [features](./features.mdx) - **Feature Toggle Configuration**: Control various analysis features of Rsdoctor, such as loader analysis, bundle analysis, rule checking, etc.
- [output](./output.mdx) - **Output Related Configuration**: Control report output format, directory and other options, including mode, options, reportCodeType, etc.
- [port](./port.mdx) - **Service Port Configuration**: Set the port number for the Rsdoctor development server, used for report preview during local development.
- [supports](./supports.mdx) - **Feature Support Configuration**: Enable compatibility support for specific build tools, such as BannerPlugin, etc.
- [brief](./brief.mdx) - **Brief Mode Configuration**: Control the generation of brief mode reports, including HTML filename and whether to generate JSON data files.
- [mode](./mode.mdx) - **Build Report Data Output Mode**: Select the output mode for reports, supporting normal (normal mode) and brief (brief mode).

### RsdoctorRspackPluginOptions

```ts
interface RsdoctorWebpackPluginOptions<
  Rules extends LinterType.ExtendRuleData[],
> {
  /** Linter configuration */
  linter?: LinterType.Options<Rules, InternalRules>;

  /** Rsdoctor feature toggles */
  features?:
    | Plugin.RsdoctorWebpackPluginFeatures
    | Array<keyof Plugin.RsdoctorWebpackPluginFeatures>;

  /**
   * @deprecated Use `output.mode` instead. If using `lite` mode, please use `output.reportCodeType: 'noCode' or 'noAssetsAndModuleSource'` instead
   * Rsdoctor mode options:
   * - normal: Normal mode
   * - brief: Brief mode, only displays duration analysis and build artifact analysis results, does not display any code parts
   */
  mode?: 'brief' | 'normal' | 'lite';

  disableClientServer?: boolean;

  supports?: ISupport;

  port?: number;

  /**
   * @deprecated Use `output.options.htmlOptions` instead
   */
  brief?: Config.BriefConfig;

  output?: Config.IOutput<'brief' | 'normal'>;

  experiments?: RsdoctorRspackPluginExperiments;
}

interface RsdoctorRspackPluginExperiments {
  /**
   * Whether to enable native plugin to improve performance
   * @default false
   */
  enableNativePlugin?: boolean;
}
```

### RsdoctorWebpackPluginOptions

RsdoctorWebpackPlugin is equivalent to `Omit<RsdoctorRspackPluginOptions, 'experiments'>` type.
